<?php


namespace app\admin\controller;


use app\common\model\VisitRegistration;
use think\Request;

class Visitrecord extends Base
{
    public function __construct()
    {
        parent::__construct();
        $this->isLogin();
    }

    /**
     * @route('visitrecord/visitrecordlist')
     * 来访记录列表
     */
    public function visitrecordlist()
    {
        $visitRegModel = new VisitRegistration();

        // 获取搜索条件
        $get['company_name'] = input('get.company_name');
        $get['time'] = input('get.time');
        // 后台账号数据
        $rs_data = $visitRegModel->get_list_page($get,'add_time,visit_reg_id desc','*', $this->limit);
        $isdisplay = true;
//        var_dump($rs_data->toArray());die;
        $time_arr = [
            '1' => "10:00-12:00",
            '2' => "14:00-16:00",
        ];
        $tvar = array(
            "title" => "来访记录列表",
            "time"  => time(),
            "data"  => $rs_data,
            "get"   => $get,
            "isdisplay" => $isdisplay,
            "time_arr" => $time_arr,
        );
        $page = $rs_data->render();
        $this->assign("data", $tvar);
        $this->assign('page', $page);
        return $this->fetch('visitrecord/visitrecordlist');
    }

    /**
     * @route('visitrecord/delrecord')
     * 删除用户
     */
    public function DelAdmin()
    {
        $Id = $_GET['id'];

        $rs = \app\common\model\Subplatform::destroy($Id);
        if($rs === false){
            $this->error("删除失败");
        }
        $this->success('删除成功 ');
    }

}